package com.example.infrastructure.application;

import com.example.infrastructure.api.organization.vo.Condition;
import com.example.infrastructure.domain.organization.aggregate.Organization;
import com.example.infrastructure.domain.organization.service.OrganizationDomainService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

/**
 * TODO
 *
 * @author lxh
 * @date 2020/11/17 下午1:24
 **/
@Service
public class OrganizationApplication {
    private final OrganizationDomainService organizationDomainService;

    public OrganizationApplication(OrganizationDomainService organizationDomainService) {
        this.organizationDomainService = organizationDomainService;
    }

    public Optional<Organization> findOne(String orgId) {
        return organizationDomainService.findByOrgId(orgId);
    }

    public List<Organization> findOrganizations(Organization request) {
        return organizationDomainService.findOrganizations(request);
    }

    public List<Organization> search(Condition condition) {
        return organizationDomainService.search(condition);
    }

    public Organization save(Organization organization) {
        return organizationDomainService.save(organization);
    }

    public void delete(String orgId) {
        organizationDomainService.deleteByOrgId(orgId);
    }
}
